package com.demo.thread.threadpool;

import java.util.concurrent.*;

/**
 * 超过了队列数还是会报拒绝异常
 */
public class SynchronousQueueTest {
    public static void main(String[] args)  {
          ExecutorService cachedThreadPool = new ThreadPoolExecutor(4, Runtime.getRuntime().availableProcessors() * 2, 0, TimeUnit.MILLISECONDS, new SynchronousQueue<>(), r -> new Thread(r, "ThreadTest"));

          for(int i =0;i<10000;i++){
              final int page = i+1;
              cachedThreadPool.execute(new Runnable() {
                  @Override
                  public void run() {
                      System.out.println("page:"+page);
                  }
              });
          }
    }
}
